package com.mdc;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;

// A filter for the URL pattern /admin:
//@WebFilter("/a-servlet")
// Apply a filter for all URLs:
//@WebFilter("/*")
// Register a filter for a specific servlet:
//@WebFilter(servletNames = "MyOwnServlet")
public class MyFilter implements Filter{
    @Override
    public void init(FilterConfig filterConfig)
            throws ServletException {
        System.out.println("MyFilter.init() is called.");
    }

    @Override
    public void doFilter(ServletRequest request,
                         ServletResponse response,
                         FilterChain chain)
            throws IOException, ServletException {
        System.out.println("MyFilter.doFilter() is called.");
        chain.doFilter(request, response);
    }

    @Override
    public void destroy() {
    }
}
